<template>
  <view class="container" :style="{height: `${windowHeight}px`}">
	  <u-subsection :list="['报工操作', '报工记录']" mode="subsection" :current="current" @change="changeCurrent"></u-subsection>
	  <view v-if="current == 0 " style="margin: 10px;">
	  	<view style="display: flex;" >
	  			  <view style="line-height: 40px;">工单号 </view>
	  			<u-search shape="round" style="margin-left: 20px;" placeholder="输入工单号" v-model="model" :clearabled="true"  :showAction="true" @custom="search" :animation="true"></u-search>
	  			<uni-icons type="scan" size="30" style="margin-top: 4px;"  @click="scanCode"></uni-icons>
	  	</view>
	  	<view style="display: flex;">
	  		操作员：<u--text type="primary" :text="user.nickName"></u--text>
	  	</view>
	  </view>
	  <view v-else style="margin: 10px;">
	  	<uni-table ref="table" width="100%" :loading="loading" stripe emptyText="暂无更多数据">
	  		<uni-tr>
	  			<uni-th width="70" align="center">条码号</uni-th>
	  			<uni-th width="70" align="center">工序名称</uni-th>
	  			<uni-th width="70" align="center">操作</uni-th>
	  		</uni-tr>
	  		<uni-tr v-for="(item, index) in tableData" :key="index">
	  			<uni-td align="center">{{ item.fabricId }}</uni-td>
	  			<uni-td align="center">{{ item.availableQuantity }}</uni-td>
	  			<uni-td align="center">{{ item.repositoryName }}</uni-td>
	  		</uni-tr>
	  	</uni-table>
		<uni-pagination v-if="total > 0" :pageSize="pageSize" :total="total" :current="current" title="标题文字" prev-text="前一页" next-text="后一页" />
	  </view>
	  
	  
  </view>
</template>

<script>
	import { listInventory, listFabric } from '@/api/fabricManagement/InventoryQuery.js'
	export default {
    data() {
      return {
		user: this.$store.state.user.userDeatails,
	    loading: false,
        windowHeight: uni.getSystemInfoSync().windowHeight,
		model: '',
		tableData: [],
		// 每页数据量
		pageSize: 10,
		// 当前页
		pageCurrent: 1,
		// 数据总量
		total: 0,
		current: 0,
		pageSize: 5
      }
    },
	watch: {
		model(val) {
			if(val) {
				// this.getListFabric()
				return
			}
			this.tableData = []
		}
	},
	onLoad() {
		// this.getList()
	},
    methods: {
		search(value) {
			console.log(value)
		},
	    clearModel() {
		  this.model = ''
	    }, 
		async scanCode() {
			const _ = this
			uni.scanCode({
				onlyFromCamera: true,
				success: function(res) {
					_.model = res.result
				}
			});
		},
		changeCurrent(e) {
			console.log(e)
			this.current = e
		}
    }
  }
</script>

<style lang="scss" scoped>
  .container {
    background-color: #fff;
	padding: 5px;
  }
  .history {
  		background: white;
  		// padding: 30rpx;
  		.history-head {
  			display: flex;
  			align-items: center;
  			text {
  				display: block;
  				flex: 1;
  				font-size: 28rpx;
  				// font-weight: bold;
  				color: black;
				padding-top: 10px;
  			}
  		}
  	}
  	.history-list {
		padding: 10px 10px 0 10px ;
  		scroll-view {
  			display: inline-block;
  			vertical-align: top;
  			background-color: #f1f1f1;
  			color: #333;
  			font-size: 16px;
  			padding: 5rpx 20rpx;
  			border-radius: 40rpx;
  			margin: 10rpx 10rpx 0 0;
  			width: fit-content;
  		}
  	}
</style>
